競プロ典型 90 問 024
種別: 記事
カテゴリ: 競技プログラミング
サブカテゴリ: AtCoder > 競プロ典型 90 問
タグ: #解いた問題
(工事中)
AtCoder で公開されている競プロ典型 90 問 の024 を解いた
解き方
解答例
下は上記の方法で解いたときの提出結果である。また、その提出の際に提出したソースコードをその下に転記する。
code: C
#include <stdio.h>
int main () {
int n = 0;
int k = 0;
int a1000 = {};
int res = 0;
long long diff = 0;
int isOK = 1;
res = scanf("%d", &n);
res = scanf("%d", &k);
for (int i = 0; i < n; i++) {
res = scanf("%d", a+i);
}
for (int i = 0; i < n; i++) {
int b = 0;
res = scanf("%d", &b);
diff += abs(ai - b);
if (isOK > 0 && diff > (long long) k) {
isOK = 0;
}
}
if (isOK <= 0 || diff > (long long) k || (k - (int) diff) % 2 != 0) {
printf("No\n");
} else {
printf("Yes\n");
}
return 0;
}
私の提出一覧
table: submissions_atcoder_typical90_024
提出のURL 提出時刻 結果 備考
1回目 https://atcoder.jp/contests/typical90/submissions/22308721 2021-05-04T22:03:14+0900 AC
感想
ローカルにおいてあったzakkan.txt(雑感)には、まだ書かれていないので、こっちに直接書く
★2なので、それほど難しくない、と思ったがちょうど$ K 回にしたいと行けないので、少し考える必要はあるのかな。
したい→しない
include も自分で定義もしていないのにabs を使ってコンパイラに怒られているのはご愛嬌で…笑
というか、これたまにやっちゃうけれど、なんで動くんやろ?gcc が気を利かせてstdlib とかリンク(?)してくれるんかな